<template>
  <el-card shadow="never">







    <el-tabs v-model="activeTab" @tab-click="handTabClick" >
      <el-tab-pane label="基础信息" name="base" >
        <BaseInfoTab :form="form" @formChange = "formChange" @cateIdChange="cateIdChange" />
      </el-tab-pane>
      <el-tab-pane label="规格库存" name="spec">
        <SpecStockTab :form="form" @formChange = "formChange"/>
      </el-tab-pane>
      <el-tab-pane label="商品详情" name="detail">
        <DetailTab :form="form" @formChange = "formChange"/>
      </el-tab-pane>
      <el-tab-pane label="物流设置" name="logistics">
        <LogisticsTab :form="form" @formChange = "formChange"/>
      </el-tab-pane>

     <!-- <el-tab-pane label="会员价/佣金" name="member">
        <MemberTab :form="form" />
      </el-tab-pane>
      <el-tab-pane label="营销设置" name="marketing">
        <MarketingTab :form="form" />
      </el-tab-pane>
      <el-tab-pane label="其他设置" name="other">
        <OtherTab :form="form" />
      </el-tab-pane> -->


    </el-tabs>


  </el-card>
</template>

<script>
import BaseInfoTab from './tabs/BaseInfoTab.vue'
import SpecStockTab from './tabs/SpecStockTab.vue'
import DetailTab from './tabs/DetailTab.vue'
import LogisticsTab from './tabs/LogisticsTab.vue'
//import MemberTab from './tabs/MemberTab.vue'
//import MarketingTab from './tabs/MarketingTab.vue'
//import OtherTab from './tabs/OtherTab.vue'

export default {
  components: {
    BaseInfoTab,
    SpecStockTab,
    DetailTab,
    LogisticsTab,
    //MemberTab,
    //MarketingTab,
    //OtherTab
  },
  data() {
    return {
      activeTab: 'base',
      form: {
        product_type: 0,
        // 基础字段
        isend_base: false,
        isend_spec: false,
        isend_detail: false,
        store_name: '',
        unit: '',
        weight: 0,
        image: '',
        slider_image: '',
        video_link: '',
        cate_id: '',
        is_show: 1,
        // 规格库存
        spec_type: 0,
        stock: 0,
        market_price: 0,
        // 商品详情
        details: '',
        // 物流设置
        is_postage: 1,
        postage: 0,
        logistics: '1,2',
        freight: 2,
        temp_id: 1,
        price:0,
        commission: 0,
        sku_object:{}

      }
    }
  },
  methods: {
    cateIdChange(data){
      this.form.cate_id=data
      console.log('***form',this.form)


    },
    formChange(data){
      this.form = { ...this.form, ...data.form };
      console.log('self----data',this.form)
      if(data.sign == '1' && this.form.isend_base){
        this.activeTab = "spec";
      }
      if(data.sign == '2' && this.form.isend_spec){
        this.activeTab = "detail";
      }

      console.log('--收到数据改变-----',data);
    },
    handTabClick(data){
      console.log('----tab切换----：', data)
      let index = data.index*1
      console.log('--收到数据改变--index---',index);
      // if(index > 0){
      //   if(!this.form.id){
      //     this.$message.error('请先录入商品基本信息');
      //   }
      // }
    },


  }
}
</script>

<style scoped>
.footer-btns {
  text-align: right;
  margin-top: 30px;
}
</style>
